import React, {lazy, ReactNode} from "react";
import {
    DashboardOutlined,
    UsergroupAddOutlined,
    UserOutlined
} from '@ant-design/icons';
const  Login = lazy(()=> import('../pages/Login/Login'));
const Page404 = lazy(() => import('../pages/404'))
const Dashboard = lazy(() => import('../pages/Dashboard'))
const UserList = lazy(() => import('../pages/User/userList'))
const Information = lazy(() => import('../pages/Information'))
const Forget = lazy(() => import('../pages/Forget'))

export interface IRouter {
    title: string;
    path: string;
    key: string;
    icon?: ReactNode,
    exact?: boolean
    component?: ReactNode;
    children?: IRouter[]
}

const router: IRouter[] = [
    {
        path: '/admin/dashboard',
        title: '仪表盘',
        key: '/admin/dashboard',
        icon: <DashboardOutlined />,
        component: <Dashboard/>
    },
    {
        path: '/admin/user',
        title: '用户管理',
        key: '/admin/user',
        icon: <UsergroupAddOutlined />,
        children: [
            {
                path: '/admin/user/list',
                title: '用户列表',
                key: '/admin/user/list',
                icon: <UserOutlined />,
                component: <UserList/>
            }
        ]
    },
];

export const AuthButNoMenu: IRouter[] = [
    {
        path: '/admin/information',
        title: '个人中心',
        key: 'information',
        component: <Information/>
    },
    {
        path: '/admin/forget',
        title: '忘记密码',
        key: 'forget',
        component: <Forget/>
    },
]

export const mergeRouter: IRouter[] = [
    ...router,
    ...AuthButNoMenu
]

/**
 * 不用安全验证的路由模式
 */
export const unAuthRouter: IRouter[] = [
    {
        path: '/login',
        title: '登录',
        exact: true,
        key: 'login',
        component: <Login/>
    },
    {
        path: '*',
        exact: false,
        title: '404',
        key: '404',
        component: <Page404/>
    }
]

export default router;
